在開始下載 Android Studio 之前,請確保你的電腦符合以下基本要求:
作業系統:Windows 10/11、macOS 10.14 或更高版本、Linux
RAM:至少 8 GB,建議 16 GB 以上
硬碟空間:至少 8 GB 的可用空間
螢幕解析度:1280 x 800 或更高
前往官方網站:
打開你的瀏覽器,並訪問 Android Studio 官方網站。
選擇下載版本:
網頁會自動檢測你的作業系統,並推薦相應的 Android Studio 版本。點擊下載按鈕即可。
接受條款與條件:
下載前,系統會要求你閱讀並接受 Google 的開發者協議。點選「我同意」後開始下載。
執行安裝程式:
下載完成後,點擊執行安裝程式。
選擇安裝路徑:
系統將要求你選擇安裝路徑,建議使用預設位置,也可以根據需求修改。
選擇安裝組件:
你可以選擇安裝的組件,通常選擇所有預設選項即可。這包括 Android Studio、Android SDK、Android 虛擬機器 (AVD) 等。
完成安裝:
安裝過程可能需要幾分鐘,安裝完成後點擊「完成」按鈕,Android Studio 將自動啟動。
首次啟動配置:
首次啟動 Android Studio 時,系統會要求你進行一些基本設置,例如選擇 UI 主題(明亮或暗色)、安裝 SDK,並設置代理。
SDK 更新與管理:
設定完成後,你可以通過「SDK Manager」來更新或安裝更多 Android SDK 平台和工具。
插件安裝:
Android Studio 支持多種插件來增強開發功能,例如 Kotlin 插件、Firebase 插件等。你可以在「Plugins」選項中搜索並安裝所需插件。
配置模擬器:
如果沒有實體裝置,你可以使用 Android 模擬器來測試應用。在「AVD Manager」中創建新的虛擬裝置,選擇所需的 Android 版本並啟動模擬器。
實體裝置連接:
將 Android 裝置連接至電腦,並確保裝置上的「開發者選項」與「USB 除錯」已啟用。Android Studio 會自動檢測並顯示你的裝置。
這些步驟完成後,你便可以開始使用 Android Studio 進行 Android 應用開發了!
想請問我的配置是以上這樣(我使用的是筆電)
但為何我要執行第一個測試的時候會藍屏
以下為我的程式碼放在main.dart中
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}